<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'ajax.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript" src="<c:url value='/jquery/jquery-1.5.1.js'/>"></script>
	
  </head>
  
  <body>
    <script type="text/javascript">
    $.ajax({
    	   url: "goods.json",//json文件位置
    	   type: "GET",//请求方式为get
    	   dataType: "json", //返回数据格式为json
    	   success: function(data) {//请求成功完成后要执行的方法 
    	       //each循环 使用$.each方法遍历返回的数据date
    	       console.log(data);
    	       $.each(data.result, function(i, item) {
    	            var str = '<div>产品ID:' + item.productId + ' 产品名：' + item.productName + 
    	            ' 产品名：' + item.productName +
    	            ' 产品价格：' + item.prodcutPrice +
    	            ' 产品图片：' + item.prodcutImg +'</div>';
    	            document.write(str);
    	       })
    	   }
    	})
    </script>
  </body>
</html>
